//
//  OCPChartsController.m
//  CJPack
//
//  Created by 陈警卫 on 2024-07-15.
//

#import "OCPChartsController.h"
#import "CJPack-Swift.h"

@interface OCPChartsController ()

@property (nonatomic, strong) CJChartsView *chartsView;

@end

@implementation OCPChartsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupChartsView];
    
}

- (void)setupChartsView {
    
    self.chartsView = [[CJChartsView alloc] initWithFrame:(CGRectMake(20, 100, self.view.cj_width - 40, self.view.cj_width - 40))];
    [self.view addSubview:self.chartsView];
    
    CJChartsAxisConfig *axis = [[CJChartsAxisConfig alloc] init];
    axis.xAxisCountForCell = 6;
    
    axis.yAxisMaxValue = 216;
    axis.yAxisMinValue = 100;
    axis.yAxisColor = [UIColor clearColor];
    
    axis.yAxisCount = 15;
    
    //axis.yAxisDashPattern = @[];
    axis.yAxisDashColor = [UIColor cj_colorWithHexStr:@"929292" alpha:0.4];
    
    axis.xAxisStyle = CJChartsXAxisStyleTime;
    
    self.chartsView.axisConfig = axis;
    
    CJChartsLineConfig *line1 = [[CJChartsLineConfig alloc] init];
    line1.style = CJChartsStyleStep;
    line1.lineColor = [UIColor cj_colorWithHexStr:@"D22007" alpha:1.0];
    line1.fillColors = @[[UIColor cj_colorWithHexStr:@"D22007" alpha:1.0], [UIColor cj_colorWithHexStr:@"D22295" alpha:1.0]];
    
    self.chartsView.lineConfigs = @[line1];
    
    [self.chartsView setupConfig];
    
    [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) {
        [self.chartsView setupValueWithPoints:@[@(arc4random_uniform(100) + 100)]];
    }];

}


@end
